package com.atguigu.gmall.mq.receiver;


import com.atguigu.gmall.mq.config.DeadLetterMqConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Date;

@Component
public class DeadLetterMessage {
    @RabbitListener(queues = DeadLetterMqConfig.queue_dead_2)
    public void message(String msg , Message message , Channel channel){
        System.out.println("接收到的消息：" + msg);
        System.out.println("接收到的消息时间：" + new Date());
        try {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
